package jwdt.xadmin.goods.action;

import jwdt.common.action.BaseAction;
import jwdt.xadmin.goods.bean.TGoods;
import jwdt.xadmin.goods.service.GoodsManageService;

import com.ezerg.db.ext.PageUtil;
import com.ezerg.web.Form;
import com.ezerg.web.Module;
import com.ezerg.web.Page;
import com.ezerg.web.annotation.Controller;
import com.ezerg.web.annotation.RequestMapping;

@Controller("/xadmin/goods")
public class GoodsManageAction extends BaseAction {

	GoodsManageService goodsManageService = app.getBean("GoodsManageService");
	
	
	
	@RequestMapping("/selectGoodsList")
	public Page doSelectGoodsList(Form f,Module m)throws Exception{
		int fid = f.getInt("fid", 0);
		PageUtil pu = (PageUtil) f.copy2Class(PageUtil.class);
		return m.getWritePage(f, goodsManageService.selectGoodsList(pu,fid).toJson());
	}
	
	@RequestMapping("/selectGoods")
	public Page doSelectGoods(Form f,Module m)throws Exception{
		return m.getJsonPage(f, goodsManageService.selectGoods());
	}
	
	@RequestMapping("/selectOneGoods")
	public Page doSelectOneGoods(Form f,Module m)throws Exception{
		int goodsid = f.getInt("goodsid");
		return m.getJsonPage(f, goodsManageService.selectOneGoods(goodsid));
	}
	
	@RequestMapping("/saveGoods")
	public Page doSaveGoods(Form f,Module m)throws Exception{
		int goodsid = f.getInt("goodsid");
		TGoods obj = (TGoods) f.copy2Class(TGoods.class);
		return m.getJsonPage(f, goodsManageService.saveGoods(goodsid, obj));
	}
	
	@RequestMapping("/delGoods")
	public Page doDelGoods(Form f,Module m)throws Exception{
		int goodsid = f.getInt("goodsid");
		return m.getJsonPage(f, goodsManageService.delGoods(goodsid));
	}
	
}
